﻿using INTEX.SCHEDULER;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using WPFExcelReport.Controls;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for Machine.xaml
    /// </summary>

    public partial class UIJOB : ViewBase
    {
        public VICC_MKRF TMV
        {
            get
            {
                return (VICC_MKRF)MV;
            }
        }
        #region ==IsABF===========
        public static readonly DependencyProperty IsABFProperty = DependencyProperty.Register("IsABF",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsABFChanged));
        public bool IsABF
        {
            get
            {
                return (bool)GetValue(IsABFProperty);
            }
            set
            {
                SetValue(IsABFProperty, value);
            }
        }
        private static void OnIsABFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsABF = (bool)e.NewValue;
                src.LOADABF();
            }
        }

        #endregion

        #region ==IsKSL===========
        public static readonly DependencyProperty IsKSLProperty = DependencyProperty.Register("IsKSL",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsKSLChanged));
        public bool IsKSL
        {
            get
            {
                return (bool)GetValue(IsKSLProperty);
            }
            set
            {
                SetValue(IsKSLProperty, value);
            }
        }
        private static void OnIsKSLChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsKSL = (bool)e.NewValue;
                src.LOADKSL();
            }
        }

        #endregion

        #region ==ProductionType===========
        public static readonly DependencyProperty ProductionTypeProperty = DependencyProperty.Register("ProductionType",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnProductionTypeChanged));
        public string ProductionType
        {
            get
            {
                return (string)GetValue(ProductionTypeProperty);
            }
            set
            {
                SetValue(ProductionTypeProperty, value);
            }
        }
        private static void OnProductionTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.ProductionType = (string)e.NewValue;
            }
        }
        #endregion
 
        #region ==JobID===========
        public static readonly DependencyProperty JobIDProperty = DependencyProperty.Register("JobID",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnJobIDChanged));
        public string JobID
        {
            get
            {
                return (string)GetValue(JobIDProperty);
            }
            set
            {
                SetValue(JobIDProperty, value);
            }
        }
        private static void OnJobIDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.JobID = (string)e.NewValue;
            }
        }
        #endregion        

        #region ==AUF===========
        public static readonly DependencyProperty AUFProperty = DependencyProperty.Register("AUF",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAUFChanged));
        public string AUF
        {
            get
            {
                return (string)GetValue(AUFProperty);
            }
            set
            {
                SetValue(AUFProperty, value);
            }
        }
        private static void OnAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.AUF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==JobType===========
        public static readonly DependencyProperty JobTypeProperty = DependencyProperty.Register("JobType",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnJobTypeChanged));
        public string JobType
        {
            get
            {
                return (string)GetValue(JobTypeProperty);
            }
            set
            {
                SetValue(JobTypeProperty, value);
            }
        }
        private static void OnJobTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.JobType = (string)e.NewValue;
                src.SetJobTypeDes();
            }
        }
        #endregion

        #region ==JobDes===========
        public static readonly DependencyProperty JobDesProperty = DependencyProperty.Register("JobDes",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnJobDesChanged));
        public string JobDes
        {
            get
            {
                return (string)GetValue(JobDesProperty);
            }
            set
            {
                SetValue(JobDesProperty, value);
            }
        }
        private static void OnJobDesChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.JobDes = (string)e.NewValue;
            }
        }
        #endregion

        #region ==JobTypeDes===========
        public static readonly DependencyProperty JobTypeDesProperty = DependencyProperty.Register("JobTypeDes",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnJobTypeDesChanged));
        public string JobTypeDes
        {
            get
            {
                return (string)GetValue(JobTypeDesProperty);
            }
            set
            {
                SetValue(JobTypeDesProperty, value);
            }
        }
        private static void OnJobTypeDesChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.JobTypeDes = (string)e.NewValue;
            }
        }
        #endregion

        #region ==JobQty===========
        public static readonly DependencyProperty JobQtyProperty = DependencyProperty.Register("JobQty",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnJobQtyChanged));
        public double JobQty
        {
            get
            {
                return (double)GetValue(JobQtyProperty);
            }
            set
            {
                SetValue(JobQtyProperty, value);
            }
        }
        private static void OnJobQtyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.JobQty = (double)e.NewValue;
            }
        }
        #endregion

        #region ==MachineID===========
        public static readonly DependencyProperty MachineIDProperty = DependencyProperty.Register("MachineID",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMachineIDChanged));
        public string MachineID
        {
            get
            {
                return (string)GetValue(MachineIDProperty);
            }
            set
            {
                SetValue(MachineIDProperty, value);
            }
        }
        private static void OnMachineIDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.MachineID = (string)e.NewValue;
            }
        }
        #endregion

        #region ==ABFBLFDNR===========
        public static readonly DependencyProperty ABFBLFDNRProperty = DependencyProperty.Register("ABFBLFDNR",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABFBLFDNRChanged));
        public string ABFBLFDNR
        {
            get
            {
                return (string)GetValue(ABFBLFDNRProperty);
            }
            set
            {
                SetValue(ABFBLFDNRProperty, value);
            }
        }
        private static void OnABFBLFDNRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.ABFBLFDNR = (string)e.NewValue;
            }
        }
        #endregion

        #region ==AWIDTH===========
        public static readonly DependencyProperty AWIDTHProperty = DependencyProperty.Register("AWIDTH",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAWIDTHChanged));
        public double AWIDTH
        {
            get
            {
                return (double)GetValue(AWIDTHProperty);
            }
            set
            {
                SetValue(AWIDTHProperty, value);
            }
        }
        private static void OnAWIDTHChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.AWIDTH = (double)e.NewValue;
            }
        }
        #endregion

        #region ==KSTKRS===========
        public static readonly DependencyProperty KSTKRSProperty = DependencyProperty.Register("KSTKRS",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKSTKRSChanged));
        public string KSTKRS
        {
            get
            {
                return (string)GetValue(KSTKRSProperty);
            }
            set
            {
                SetValue(KSTKRSProperty, value);
                OnKSTKRSChg(value);
            }
        }
        private static void OnKSTKRSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.KSTKRS = (string)e.NewValue;
            }
        }
        public virtual void OnKSTKRSChg(string value)
        { }
        #endregion

        #region ==MACHINEID===========
        public static readonly DependencyProperty MACHINEIDProperty = DependencyProperty.Register("MACHINEID",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMACHINEIDChanged));
        public string MACHINEID
        {
            get
            {
                return (string)GetValue(MACHINEIDProperty);
            }
            set
            {
                SetValue(MACHINEIDProperty, value);
            }
        }
        private static void OnMACHINEIDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.MACHINEID = (string)e.NewValue;
            }
        }
        #endregion 

        #region ==KST===========
        public static readonly DependencyProperty KSTProperty = DependencyProperty.Register("KST",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKSTChanged));
        public string KST
        {
            get
            {
                return (string)GetValue(KSTProperty);
            }
            set
            {
                SetValue(KSTProperty, value);
                OnKSTChg(value);
            }
        }
        private static void OnKSTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.KST = (string)e.NewValue;
            }
        }
        public virtual void OnKSTChg(string value)
        { }
        #endregion

        #region ==AMTYP===========
        public static readonly DependencyProperty AMTYPProperty = DependencyProperty.Register("AMTYP",
            typeof(string), typeof(UIJOB),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAMTYPChanged));
        public string AMTYP
        {
            get
            {
                return (string)GetValue(AMTYPProperty);
            }
            set
            {
                SetValue(AMTYPProperty, value);
                OnAMTYPChg(value);
            }
        }
        private static void OnAMTYPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.AMTYP = (string)e.NewValue;
            }
        }

        public virtual void OnAMTYPChg(string value)
        { }
        #endregion
     
        private DateTime _CalendarStart;
        public DateTime CalendarStart
        {
            get
            {
                return MCALENDAR.CalendarStart;
            }
            set            
            {
                _CalendarStart = value;
            }
    
        }

        public MCALENDAR MCALENDAR
        {
            get;
            set;
        }

        public void SetJobTypeDes()
        {
            switch (JobType)
            {
                case "P":
                    JobTypeDes = "生产";
                    break;
                case "S":
                    JobTypeDes = "自排";
                    break;
                case "C":
                    JobTypeDes = "确认";
                    break;
                case "X":
                    JobTypeDes = "日历";
                    break;
            }

        }

        public NameScope PageScope
        {
            get;
            set;
        }

        public DataTable ABFOLGE
        {
            get;
            set;
        }
      
        Grid StepShow
        {
            get
            {
                return this.FindName("Steps") as Grid;
            }
        }

        public MGANTT MGANTT
        {
            get
            {
                return Machine.MGANTT;
            }
        }

        private UIAM machine;
        public UIAM Machine
        {
            get
            {
                return machine;
            }
            set
            {
                machine = value;
                if (value != null)
                {
                   // MachineID = value.MachineID;
                }
            }
        }

        public DateTime StartDate = new DateTime();
        public DateTime EndDate = new DateTime();

        public DataTable KSLEIST
        {
            get;
            set;
        }

        public DataRow dwJob
        {
            get;
            set;
        }

        public DataRow dwMask
        {
            get;
            set;
        }

        public int MinPixes = 0;
        private double _NMQTYPLAN; public double NMQTYPLAN { get { return _NMQTYPLAN; } set { _NMQTYPLAN = value; } }
        private double _MQTYPLAN; public double MQTYPLAN { get { return _MQTYPLAN; } set { _MQTYPLAN = value; } }
        private double _NMQTYBOOK; public double NMQTYBOOK { get { return _NMQTYBOOK; } set { _NMQTYBOOK = value; } }
        private double _MQTYBOOK; public double MQTYBOOK { get { return _MQTYBOOK; } set { _MQTYBOOK = value; } }
        private double _MQTYUSED; public double MQTYUSED { get { return Helper.RoundX(_MQTYUSED, 1); } set { _MQTYUSED = value; } }
        private double _QTYACT; public double QTYACT { get { return _QTYACT; } set { _QTYACT = value; } }
        private double _NPQTYPLAN; public double NPQTYPLAN { get { return _NPQTYPLAN; } set { _NPQTYPLAN = value; } }
        private double _PQTYPLAN; public double PQTYPLAN { get { return Helper.RoundX(_PQTYPLAN, 1); } set { _PQTYPLAN = value; } }

        private double _PACTPLAN; public double PACTPLAN { get { if (JobQty == 0)   return 0; return Helper.RoundX(Convert.ToDouble(100 * QTYACT / JobQty), 1); } set { _PACTPLAN = value; } }
        private double _PMACTPLAN;

        public double PMACTPLAN
        {
            get { if (MQTYPLAN == 0)   return 0; return Helper.RoundX(Convert.ToDouble(100 * MQTYUSED / MQTYPLAN), 1); }
            set { _PMACTPLAN = value; }
        }

        private string _CR; public string CR { get { return _CR; } set { _CR = value; } }
        private string _CG; public string CG { get { return _CG; } set { _CG = value; } }
        private string _CB; public string CB { get { return _CB; } set { _CB = value; } }

        public bool IsStart = false;
        public bool IsEnd = false;

        public UIJOB() : base()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            PLANDATE = new ITXDateTime();
            ACTDATE = new ITXDateTime();
            MV = new VICC_MKRF();
            DataContext = MV;
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {  
            base.vwMaster_CurrentChanged(sender, e);
        }
        public virtual void SetUp()
        {
            TMV.dwMaster = dwJob;
            JobFace();
            ColorDef();
            FlowSteps();
            Dates();
            
            //初始化显示单元
            JobMask();
            //生产产量信息
            Production();
            //原料信息
            Material();
            //加工步骤
            
        }

        public virtual void JobFace()
        {
            this.Name = JobID;
            JobType = TMV.JOBTYPE;
            string jobname = dwJob["ABFAUFKRS"].ToString()
                    + "-" + Helper.GetSubRollNum(dwJob["ABFAUFLFD"].ToString())
                    + "-" + Helper.GetSubRollNum(dwJob["ABFAUFPOS"].ToString())
                    + "_" + Convert.ToInt16(dwJob["MKFTP"].ToString());
            jobname += "***";
            jobname = jobname.Replace("_0***", "");
            jobname = jobname.Replace("***", "");
            AUF = jobname;
            LFD = Helper.GetSubRollNum(dwJob["ABFAUFLFD"].ToString());
            ART = Helper.GetGB2312Value(dwJob["ABPART"].ToString()).Trim();
            FARBE = Helper.GetGB2312Value(dwJob["ABPFARBE"].ToString()).Trim();
            FINISH = Helper.GetGB2312Value(dwJob["ABPBESCHICH"].ToString()).Trim();           
            
            if (!PageScope.ContainsKey(Name))
            {
                PageScope.RegisterName(Name, this);
            }
        }

        public ITXDateTime PLANDATE
        {
            get;
            set;
        }

        public ITXDateTime ACTDATE
        {
            get;
            set;
        }
     
        public virtual void FlowSteps()
        {

            if (ABFOLGE == null)
                return;
            if (StepShow == null)
                return;
            try
            {
                Step Step;
                int idx = 0;
                string processedstep = "";
                var qF = (from DataRow row in ABFOLGE.AsEnumerable()
                          select row).Distinct();
                foreach (DataRow dwABFOLGE in qF)
                {
                    Step = new Step();
                    string step = dwABFOLGE["ABFAFOLGE"].ToString();
                    if (processedstep.Contains(step + ";")) continue;
                    processedstep += step + ";";
                    Step.dwABFOLGE = dwABFOLGE;
                    if (KSLEIST != null)
                    {
                        filter = "KSLAFOLGE='" + dwABFOLGE["ABFAFOLGE"].ToString() + "'";
                        sort = "KSLMDAT ASC";
                        DataRow[] rows = KSLEIST.Select(filter, sort);
                        if (rows.Length > 0)
                        {
                            DataTable tb = KSLEIST.Select(filter, sort).CopyToDataTable();
                            tb.TableName = "KSLEIST";
                            Step.KSLEIST = tb;
                        }
                    }
                    Step.SetUp();
                    Step.SetValue(Grid.ColumnProperty, idx);
                    idx++;
                    StepShow.Children.Add(Step);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private SolidColorBrush _JBrush; public SolidColorBrush JBrush { get { return _JBrush; } set { _JBrush = value; } }
        Border JBorder
        {
            get
            {
                return (Border)this.FindName("border");
            }
        }

        public int StartPoint
        {
            get;
            set;
        }

        public int GRIDS
        {
            get;
            set;
        }

        public double PIXELS
        {
            get
            {
                return MGANTT.PIXELS;
            }
        }

        public TSHAV13 PR01
        {
            get
            {
                return this.FindName("P01") as TSHAV13;
            }
        }

        public TSHAV13 PR02
        {
            get
            {
                return this.FindName("P02") as TSHAV13;
            }
        }

        public TSHAV13 PR03
        {
            get
            {
                return this.FindName("P03") as TSHAV13;
            }
        }

        public TSHAV13 PR04
        {
            get
            {
                return this.FindName("P04") as TSHAV13;
            }
        }

        public Grid MasterGrid
        {
            get
            {
                return (this.FindName("MGrid")) as Grid;
            }
        }

        public void PositionJob(UIAM m)
        { 
            Machine = m;
            
            if (PageScope.ContainsKey(Name))
            {
                PageScope.UnregisterName(Name);
            }
            DependencyObject parent = this.Parent;
            if (parent != null)
            {
                //parent.SetValue(ContentProperty, null);
                parent = null;
            } 
            SetColumns();
            if (PR01 != null)
            {
                PR01.Start = this.CalendarStart;
                PR01.AWIDTH = AWIDTH;
                PR01.GetCalendarPosition(PLANDATE);
            }
            if (PR02 != null)
            {
                PR01.Start = this.CalendarStart;
                PR01.AWIDTH = AWIDTH;
                PR02.GetCalendarPosition(ACTDATE);
            }
            StartPoint = MCALENDAR.GetPosition(StartDate); ;
            Expand();
            double MJNUM = Convert.ToDouble(Machine.MJNUM);
            double MJQTY = Convert.ToDouble(Machine.MJQTY);
            Machine.MJNUM = (MJNUM + 1).ToString();
            MJQTY = MJQTY + Convert.ToDouble(JobQty);
            Machine.MJQTY = MJQTY.ToString();
            SetPosition();
            MGANTT.MainGrid.Children.Add(this);
            PageScope.RegisterName(Name, this);
        }

        public void SetColumns()
        {
            ColumnDefinition cd;
            int TotalBlocks = Convert.ToInt16(Math.Round(MinPixes / PIXELS));
            for (int i = 0; i < TotalBlocks; i++)
            {
                cd = new ColumnDefinition();
                cd.Width = new GridLength(PIXELS);
                MasterGrid.ColumnDefinitions.Add(cd);
            }
        }

        public void Expand()
        {
            ColumnDefinition cd;
            int TotalBlocks = Convert.ToInt16(Math.Round(MinPixes / PIXELS));
            if (PR01 == null)
                return;

            if (GRIDS < TotalBlocks)
                return;
            for (int i = 0; i < GRIDS - TotalBlocks; i++)
            {
                cd = new ColumnDefinition();
                cd.Width = new GridLength(PIXELS);
                MasterGrid.ColumnDefinitions.Add(cd);
            }
        }

        private void SetPosition()
        {
            this.SetValue(Grid.RowProperty, 0);
            this.SetValue(Grid.RowSpanProperty, 2);            
            this.SetValue(Grid.ColumnProperty, StartPoint);
            int RelativeStart = 0;

            if (PR01 != null)
            {
                RelativeStart = PR01.StartPoint - StartPoint;
                if (RelativeStart < 0)
                    RelativeStart = 0;
                PR01.SetValue(Grid.ColumnProperty, RelativeStart);
                PR01.SetValue(Grid.ColumnSpanProperty, PR01.GRIDS);
            }
            if (PR02 != null)
            {
                RelativeStart = PR02.StartPoint - StartPoint;
                if (RelativeStart < 0)
                    RelativeStart = 0;
                PR02.SetValue(Grid.ColumnProperty, RelativeStart);
                PR02.SetValue(Grid.ColumnSpanProperty, PR02.GRIDS);
            }
            if (GRIDS * MGANTT.PIXELS < MinPixes)
            {
                //GRIDS = Convert.ToInt16(Math.Round(MinPixes / MGANTT.PIXELS));
                this.SetValue(Grid.ColumnSpanProperty, GRIDS);
            }
            else
            {
                this.SetValue(Grid.ColumnSpanProperty, GRIDS);
            }
            if (JobType == "X")
            {
                this.Visibility = Visibility.Collapsed;
            }
            AWIDTH = GRIDS * MGANTT.PIXELS;
        }

        public void LOADABF()
        {
            if (!IsABF)
                return;
            if (ABFOLGE != null)
                return;
            DataRow dwData = VABFOLGE.Instance.SetProd.Tables["ABFOLGE"].NewRow();
            dwData["ABFMANDANT"] = app.Mandant;
            dwData["ABFAUFKRS"] = dwJob["ABFAUFKRS"];
            dwData["ABFAUFLFD"] = dwJob["ABFAUFLFD"];
            dwData["ABFAUFPOS"] = dwJob["ABFAUFPOS"];
            SResult = VABFOLGE.Instance.QueryABFOLGE(dwData, 1);
            ABFOLGE = SResult.Tables[0].Copy();

        }

        public void LOADKSL()
        {
            if (!IsKSL)
                return;
            if (KSLEIST != null)
                return;
            dwData = VABFOLGE.Instance.TBMain.NewRow();
            dwData["KSLMANDANT"] = app.Mandant;
            dwData["KSLAUFKRS"] = dwJob["ABFAUFKRS"];
            dwData["KSLAUFLFD"] = dwJob["ABFAUFLFD"];
            dwData["KSLAUFPOS"] = dwJob["ABFAUFPOS"];
            SResult = VKSLEIST.Instance.QueryKSLEIST(dwData, 4);
            KSLEIST = SResult.Tables[0].Copy();
        }

        public virtual void Dates()
        {
            if (dwJob["MKFERLKZ"].ToString().Trim().Length > 0)
                IsEnd = true;

            switch (JobType)
            {
                case "P"://生产   
                case "C":
                case "S"://排产和固定排产
                case "X"://停工维护不更新设备的完成时间，但是开始和结束时间的时候，要定位遇到的障碍，如果跨越，如何表达：直接把时间加到本加工任务上，然后表明有维修？
                default:
                    //MKFPLDATV，MKFPLTIME，ENDATE，ENDTIME
                    PLANDATE.StartDate = dwJob["MKFPLDATV"].ToString();
                    PLANDATE.StartTime = dwJob["MKFPLTIME"].ToString();
                    PLANDATE.EndDate = dwJob["ENDATE"].ToString();
                    PLANDATE.EndTime = dwJob["ENDTIME"].ToString();

                    PLANDATE.ProcessTime = Convert.ToDouble(dwJob["ABFAMASCHZT"].ToString());
                    if (dwJob["ABFISTARTDAT"].ToString().Trim() == "0")
                        IsStart = false;
                    else
                        IsStart = true;
                    if (!IsStart)
                    {
                        ACTDATE.StartDate = "0";
                        ACTDATE.EndDate = "0";
                        break;
                    }
                    ACTDATE.ProcessTime = Convert.ToDouble(dwJob["ABFAMASCHZT"].ToString());
                    ACTDATE.StartDate = dwJob["ABFISTARTDAT"].ToString();
                    ACTDATE.StartTime = dwJob["ABFISTARTZT"].ToString();
                    ACTDATE.EndDate = dwJob["ABFIENDDAT"].ToString();
                    ACTDATE.EndTime = dwJob["ABFIENDZT"].ToString();
                    //ABFISTARTDAT,ABFISTARTZT,ABFIENDDAT,ABFIENDZT
                    if (!IsEnd)
                    {
                        DateTime m_date = ACTDATE.StartDateTime.AddMinutes(ACTDATE.ProcessTime);
                        string enddate = "0", endtime = "0";
                        Helper.GetStdDate(ref enddate, ref endtime, m_date);
                        ACTDATE.EndDate = enddate;
                        ACTDATE.EndTime = endtime;
                        ACTDATE.EndDateTime = m_date;
                        dwJob["ABFIENDDAT"] = enddate;
                        dwJob["ABFIENDZT"] = endtime;
                    }
                    break;
            }
            int t1 = DateTime.Compare(PLANDATE.StartDateTime, ACTDATE.StartDateTime);
            int t2 = DateTime.Compare(PLANDATE.EndDateTime, ACTDATE.EndDateTime);
            if (t1 >= 0)
            {
                StartDate = ACTDATE.StartDateTime;
                if (ACTDATE.StartDate == "0")
                {
                    StartDate = PLANDATE.StartDateTime;
                }
            }
            else
            {
                StartDate = PLANDATE.StartDateTime;
            }
            if (t2 >= 0)
            {
                EndDate = PLANDATE.EndDateTime;

            }
            else
            {
                EndDate = ACTDATE.EndDateTime;
            }
            GRIDS = Convert.ToInt32(EndDate.Subtract(StartDate).TotalHours + 1);
            if (GRIDS < 24)
                GRIDS = 24;
            if (GRIDS > 24 * 60)
                GRIDS = 24 * 60;
            if (PR01 != null)
            {
                PR01.SetUp();
            }
            if (PR02 != null)
            {
                PR02.SetUp();
            }
        }

        public virtual void ColorDef()
        {
            CR = dwJob["CR"].ToString();
            CG = dwJob["CG"].ToString();
            CB = dwJob["CB"].ToString();
            JBrush = new SolidColorBrush();
            if (CR == "000" && CG == "000" && CB == "000")
            {
                Random random = new Random();
                CR = random.Next(0, 255).ToString();
                CG = random.Next(0, 255).ToString();
                CB = random.Next(0, 255).ToString();
            }
            byte cr = Convert.ToByte(CR);
            byte cg = Convert.ToByte(CG);
            byte cb = Convert.ToByte(CB);  
            TMV.JobColor = Color.FromRgb(cr, cg, cb); 
            JBorder.BorderBrush = JBrush;
        }
    }

    public partial class UIJOB
    {
        
        private double _WDRESERV; public double WDRESERV { get { return _WDRESERV; } set { _WDRESERV = value; } }
        private double _WDZUGET; public double WDZUGET { get { return _WDZUGET; } set { _WDZUGET = value; } }
        private double _WDBEDARF; public double WDBEDARF { get { return _WDBEDARF; } set { _WDBEDARF = value; } }
        #region ==IsHit===========
        public static readonly DependencyProperty IsHitProperty = DependencyProperty.Register("IsHit",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsHitChanged));
        public bool IsHit
        {
            get
            {
                return (bool)GetValue(IsHitProperty);
            }
            set
            {
                SetValue(IsHitProperty, value);
            }
        }
        private static void OnIsHitChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsHit = (bool)e.NewValue;
            }
        }

        #endregion
        
        #region ==GAKG1===========
        public static readonly DependencyProperty GAKG1Property = DependencyProperty.Register("GAKG1",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAKG1Changed));
        public double GAKG1
        {
            get
            {
                return (double)GetValue(GAKG1Property);
            }
            set
            {
                SetValue(GAKG1Property, value);
            }
        }
        private static void OnGAKG1Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.GAKG1 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==GAKG2===========
        public static readonly DependencyProperty GAKG2Property = DependencyProperty.Register("GAKG2",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAKG2Changed));
        public double GAKG2
        {
            get
            {
                return (double)GetValue(GAKG2Property);
            }
            set
            {
                SetValue(GAKG2Property, value);
            }
        }
        private static void OnGAKG2Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.GAKG2 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==GAKG3===========
        public static readonly DependencyProperty GAKG3Property = DependencyProperty.Register("GAKG3",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAKG3Changed));
        public double GAKG3
        {
            get
            {
                return (double)GetValue(GAKG3Property);
            }
            set
            {
                SetValue(GAKG3Property, value);
            }
        }
        private static void OnGAKG3Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.GAKG3 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==GAKG4===========
        public static readonly DependencyProperty GAKG4Property = DependencyProperty.Register("GAKG4",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAKG4Changed));
        public double GAKG4
        {
            get
            {
                return (double)GetValue(GAKG4Property);
            }
            set
            {
                SetValue(GAKG4Property, value);
            }
        }
        private static void OnGAKG4Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.GAKG4 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==GAKG5===========
        public static readonly DependencyProperty GAKG5Property = DependencyProperty.Register("GAKG5",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAKG5Changed));
        public double GAKG5
        {
            get
            {
                return (double)GetValue(GAKG5Property);
            }
            set
            {
                SetValue(GAKG5Property, value);
            }
        }
        private static void OnGAKG5Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.GAKG5 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==GAKG6===========
        public static readonly DependencyProperty GAKG6Property = DependencyProperty.Register("GAKG6",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAKG6Changed));
        public double GAKG6
        {
            get
            {
                return (double)GetValue(GAKG6Property);
            }
            set
            {
                SetValue(GAKG6Property, value);
            }
        }
        private static void OnGAKG6Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.GAKG6 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==GAKG7===========
        public static readonly DependencyProperty GAKG7Property = DependencyProperty.Register("GAKG7",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAKG7Changed));
        public double GAKG7
        {
            get
            {
                return (double)GetValue(GAKG7Property);
            }
            set
            {
                SetValue(GAKG7Property, value);
            }
        }
        private static void OnGAKG7Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.GAKG7 = (double)e.NewValue;
            }
        }
        #endregion

        #region ==BAMTR1===========
        public static readonly DependencyProperty BAMTR1Property = DependencyProperty.Register("BAMTR1",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBAMTR1Changed));
        public double BAMTR1
        {
            get
            {
                return (double)GetValue(BAMTR1Property);
            }
            set
            {
                SetValue(BAMTR1Property, value);
            }
        }
        private static void OnBAMTR1Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.BAMTR1 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==BAMTR2===========
        public static readonly DependencyProperty BAMTR2Property = DependencyProperty.Register("BAMTR2",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBAMTR2Changed));
        public double BAMTR2
        {
            get
            {
                return (double)GetValue(BAMTR2Property);
            }
            set
            {
                SetValue(BAMTR2Property, value);
            }
        }
        private static void OnBAMTR2Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.BAMTR2 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==BAMTR3===========
        public static readonly DependencyProperty BAMTR3Property = DependencyProperty.Register("BAMTR3",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBAMTR3Changed));
        public double BAMTR3
        {
            get
            {
                return (double)GetValue(BAMTR3Property);
            }
            set
            {
                SetValue(BAMTR3Property, value);
            }
        }
        private static void OnBAMTR3Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.BAMTR3 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==BAMTR4===========
        public static readonly DependencyProperty BAMTR4Property = DependencyProperty.Register("BAMTR4",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBAMTR4Changed));
        public double BAMTR4
        {
            get
            {
                return (double)GetValue(BAMTR4Property);
            }
            set
            {
                SetValue(BAMTR4Property, value);
            }
        }
        private static void OnBAMTR4Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.BAMTR4 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==BAMTR5===========
        public static readonly DependencyProperty BAMTR5Property = DependencyProperty.Register("BAMTR5",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBAMTR5Changed));
        public double BAMTR5
        {
            get
            {
                return (double)GetValue(BAMTR5Property);
            }
            set
            {
                SetValue(BAMTR5Property, value);
            }
        }
        private static void OnBAMTR5Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.BAMTR5 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==BAMTR6===========
        public static readonly DependencyProperty BAMTR6Property = DependencyProperty.Register("BAMTR6",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBAMTR6Changed));
        public double BAMTR6
        {
            get
            {
                return (double)GetValue(BAMTR6Property);
            }
            set
            {
                SetValue(BAMTR6Property, value);
            }
        }
        private static void OnBAMTR6Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.BAMTR6 = (double)e.NewValue;
            }
        }
        #endregion
        #region ==BAMTR7===========
        public static readonly DependencyProperty BAMTR7Property = DependencyProperty.Register("BAMTR7",
            typeof(double), typeof(UIJOB),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBAMTR7Changed));
        public double BAMTR7
        {
            get
            {
                return (double)GetValue(BAMTR7Property);
            }
            set
            {
                SetValue(BAMTR7Property, value);
            }
        }
        private static void OnBAMTR7Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.BAMTR7 = (double)e.NewValue;
            }
        }
        #endregion

        #region ==IsPR01===========
        public static readonly DependencyProperty IsPR01Property = DependencyProperty.Register("IsPR01",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR01Changed));
        public bool IsPR01
        {
            get
            {
                return (bool)GetValue(IsPR01Property);
            }
            set
            {
                SetValue(IsPR01Property, value);
            }
        }
        private static void OnIsPR01Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR01 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR02===========
        public static readonly DependencyProperty IsPR02Property = DependencyProperty.Register("IsPR02",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR02Changed));
        public bool IsPR02
        {
            get
            {
                return (bool)GetValue(IsPR02Property);
            }
            set
            {
                SetValue(IsPR02Property, value);
            }
        }
        private static void OnIsPR02Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR02 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR03===========
        public static readonly DependencyProperty IsPR03Property = DependencyProperty.Register("IsPR03",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR03Changed));
        public bool IsPR03
        {
            get
            {
                return (bool)GetValue(IsPR03Property);
            }
            set
            {
                SetValue(IsPR03Property, value);
            }
        }
        private static void OnIsPR03Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR03 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR04===========
        public static readonly DependencyProperty IsPR04Property = DependencyProperty.Register("IsPR04",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR04Changed));
        public bool IsPR04
        {
            get
            {
                return (bool)GetValue(IsPR04Property);
            }
            set
            {
                SetValue(IsPR04Property, value);
            }
        }
        private static void OnIsPR04Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR04 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR05===========
        public static readonly DependencyProperty IsPR05Property = DependencyProperty.Register("IsPR05",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR05Changed));
        public bool IsPR05
        {
            get
            {
                return (bool)GetValue(IsPR05Property);
            }
            set
            {
                SetValue(IsPR05Property, value);
            }
        }
        private static void OnIsPR05Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR05 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR06===========
        public static readonly DependencyProperty IsPR06Property = DependencyProperty.Register("IsPR06",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR06Changed));
        public bool IsPR06
        {
            get
            {
                return (bool)GetValue(IsPR06Property);
            }
            set
            {
                SetValue(IsPR06Property, value);
            }
        }
        private static void OnIsPR06Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR06 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR07===========
        public static readonly DependencyProperty IsPR07Property = DependencyProperty.Register("IsPR07",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR07Changed));
        public bool IsPR07
        {
            get
            {
                return (bool)GetValue(IsPR07Property);
            }
            set
            {
                SetValue(IsPR07Property, value);
            }
        }
        private static void OnIsPR07Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR07 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR08===========
        public static readonly DependencyProperty IsPR08Property = DependencyProperty.Register("IsPR08",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR08Changed));
        public bool IsPR08
        {
            get
            {
                return (bool)GetValue(IsPR08Property);
            }
            set
            {
                SetValue(IsPR08Property, value);
            }
        }
        private static void OnIsPR08Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR08 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsPR09===========
        public static readonly DependencyProperty IsPR09Property = DependencyProperty.Register("IsPR09",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsPR09Changed));
        public bool IsPR09
        {
            get
            {
                return (bool)GetValue(IsPR09Property);
            }
            set
            {
                SetValue(IsPR09Property, value);
            }
        }
        private static void OnIsPR09Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsPR09 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN01===========
        public static readonly DependencyProperty IsCN01Property = DependencyProperty.Register("IsCN01",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN01Changed));
        public bool IsCN01
        {
            get
            {
                return (bool)GetValue(IsCN01Property);
            }
            set
            {
                SetValue(IsCN01Property, value);
            }
        }
        private static void OnIsCN01Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN01 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN02===========
        public static readonly DependencyProperty IsCN02Property = DependencyProperty.Register("IsCN02",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN02Changed));
        public bool IsCN02
        {
            get
            {
                return (bool)GetValue(IsCN02Property);
            }
            set
            {
                SetValue(IsCN02Property, value);
            }
        }
        private static void OnIsCN02Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN02 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN03===========
        public static readonly DependencyProperty IsCN03Property = DependencyProperty.Register("IsCN03",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN03Changed));
        public bool IsCN03
        {
            get
            {
                return (bool)GetValue(IsCN03Property);
            }
            set
            {
                SetValue(IsCN03Property, value);
            }
        }
        private static void OnIsCN03Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN03 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN04===========
        public static readonly DependencyProperty IsCN04Property = DependencyProperty.Register("IsCN04",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN04Changed));
        public bool IsCN04
        {
            get
            {
                return (bool)GetValue(IsCN04Property);
            }
            set
            {
                SetValue(IsCN04Property, value);
            }
        }
        private static void OnIsCN04Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN04 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN05===========
        public static readonly DependencyProperty IsCN05Property = DependencyProperty.Register("IsCN05",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN05Changed));
        public bool IsCN05
        {
            get
            {
                return (bool)GetValue(IsCN05Property);
            }
            set
            {
                SetValue(IsCN05Property, value);
            }
        }
        private static void OnIsCN05Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN05 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN06===========
        public static readonly DependencyProperty IsCN06Property = DependencyProperty.Register("IsCN06",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN06Changed));
        public bool IsCN06
        {
            get
            {
                return (bool)GetValue(IsCN06Property);
            }
            set
            {
                SetValue(IsCN06Property, value);
            }
        }
        private static void OnIsCN06Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN06 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN07===========
        public static readonly DependencyProperty IsCN07Property = DependencyProperty.Register("IsCN07",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN07Changed));
        public bool IsCN07
        {
            get
            {
                return (bool)GetValue(IsCN07Property);
            }
            set
            {
                SetValue(IsCN07Property, value);
            }
        }
        private static void OnIsCN07Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN07 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN08===========
        public static readonly DependencyProperty IsCN08Property = DependencyProperty.Register("IsCN08",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN08Changed));
        public bool IsCN08
        {
            get
            {
                return (bool)GetValue(IsCN08Property);
            }
            set
            {
                SetValue(IsCN08Property, value);
            }
        }
        private static void OnIsCN08Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN08 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsCN09===========
        public static readonly DependencyProperty IsCN09Property = DependencyProperty.Register("IsCN09",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCN09Changed));
        public bool IsCN09
        {
            get
            {
                return (bool)GetValue(IsCN09Property);
            }
            set
            {
                SetValue(IsCN09Property, value);
            }
        }
        private static void OnIsCN09Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsCN09 = (bool)e.NewValue;
            }
        }

        #endregion

        #region ==IsDN01===========
        public static readonly DependencyProperty IsDN01Property = DependencyProperty.Register("IsDN01",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN01Changed));
        public bool IsDN01
        {
            get
            {
                return (bool)GetValue(IsDN01Property);
            }
            set
            {
                SetValue(IsDN01Property, value);
            }
        }
        private static void OnIsDN01Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN01 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN02===========
        public static readonly DependencyProperty IsDN02Property = DependencyProperty.Register("IsDN02",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN02Changed));
        public bool IsDN02
        {
            get
            {
                return (bool)GetValue(IsDN02Property);
            }
            set
            {
                SetValue(IsDN02Property, value);
            }
        }
        private static void OnIsDN02Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN02 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN03===========
        public static readonly DependencyProperty IsDN03Property = DependencyProperty.Register("IsDN03",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN03Changed));
        public bool IsDN03
        {
            get
            {
                return (bool)GetValue(IsDN03Property);
            }
            set
            {
                SetValue(IsDN03Property, value);
            }
        }
        private static void OnIsDN03Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN03 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN04===========
        public static readonly DependencyProperty IsDN04Property = DependencyProperty.Register("IsDN04",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN04Changed));
        public bool IsDN04
        {
            get
            {
                return (bool)GetValue(IsDN04Property);
            }
            set
            {
                SetValue(IsDN04Property, value);
            }
        }
        private static void OnIsDN04Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN04 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN05===========
        public static readonly DependencyProperty IsDN05Property = DependencyProperty.Register("IsDN05",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN05Changed));
        public bool IsDN05
        {
            get
            {
                return (bool)GetValue(IsDN05Property);
            }
            set
            {
                SetValue(IsDN05Property, value);
            }
        }
        private static void OnIsDN05Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN05 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN06===========
        public static readonly DependencyProperty IsDN06Property = DependencyProperty.Register("IsDN06",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN06Changed));
        public bool IsDN06
        {
            get
            {
                return (bool)GetValue(IsDN06Property);
            }
            set
            {
                SetValue(IsDN06Property, value);
            }
        }
        private static void OnIsDN06Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN06 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN07===========
        public static readonly DependencyProperty IsDN07Property = DependencyProperty.Register("IsDN07",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN07Changed));
        public bool IsDN07
        {
            get
            {
                return (bool)GetValue(IsDN07Property);
            }
            set
            {
                SetValue(IsDN07Property, value);
            }
        }
        private static void OnIsDN07Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN07 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN08===========
        public static readonly DependencyProperty IsDN08Property = DependencyProperty.Register("IsDN08",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN08Changed));
        public bool IsDN08
        {
            get
            {
                return (bool)GetValue(IsDN08Property);
            }
            set
            {
                SetValue(IsDN08Property, value);
            }
        }
        private static void OnIsDN08Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN08 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsDN09===========
        public static readonly DependencyProperty IsDN09Property = DependencyProperty.Register("IsDN09",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDN09Changed));
        public bool IsDN09
        {
            get
            {
                return (bool)GetValue(IsDN09Property);
            }
            set
            {
                SetValue(IsDN09Property, value);
            }
        }
        private static void OnIsDN09Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsDN09 = (bool)e.NewValue;
            }
        }

        #endregion

        #region ==IsFL01===========
        public static readonly DependencyProperty IsFL01Property = DependencyProperty.Register("IsFL01",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL01Changed));
        public bool IsFL01
        {
            get
            {
                return (bool)GetValue(IsFL01Property);
            }
            set
            {
                SetValue(IsFL01Property, value);
            }
        }
        private static void OnIsFL01Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL01 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL02===========
        public static readonly DependencyProperty IsFL02Property = DependencyProperty.Register("IsFL02",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL02Changed));
        public bool IsFL02
        {
            get
            {
                return (bool)GetValue(IsFL02Property);
            }
            set
            {
                SetValue(IsFL02Property, value);
            }
        }
        private static void OnIsFL02Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL02 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL03===========
        public static readonly DependencyProperty IsFL03Property = DependencyProperty.Register("IsFL03",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL03Changed));
        public bool IsFL03
        {
            get
            {
                return (bool)GetValue(IsFL03Property);
            }
            set
            {
                SetValue(IsFL03Property, value);
            }
        }
        private static void OnIsFL03Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL03 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL04===========
        public static readonly DependencyProperty IsFL04Property = DependencyProperty.Register("IsFL04",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL04Changed));
        public bool IsFL04
        {
            get
            {
                return (bool)GetValue(IsFL04Property);
            }
            set
            {
                SetValue(IsFL04Property, value);
            }
        }
        private static void OnIsFL04Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL04 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL05===========
        public static readonly DependencyProperty IsFL05Property = DependencyProperty.Register("IsFL05",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL05Changed));
        public bool IsFL05
        {
            get
            {
                return (bool)GetValue(IsFL05Property);
            }
            set
            {
                SetValue(IsFL05Property, value);
            }
        }
        private static void OnIsFL05Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL05 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL06===========
        public static readonly DependencyProperty IsFL06Property = DependencyProperty.Register("IsFL06",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL06Changed));
        public bool IsFL06
        {
            get
            {
                return (bool)GetValue(IsFL06Property);
            }
            set
            {
                SetValue(IsFL06Property, value);
            }
        }
        private static void OnIsFL06Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL06 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL07===========
        public static readonly DependencyProperty IsFL07Property = DependencyProperty.Register("IsFL07",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL07Changed));
        public bool IsFL07
        {
            get
            {
                return (bool)GetValue(IsFL07Property);
            }
            set
            {
                SetValue(IsFL07Property, value);
            }
        }
        private static void OnIsFL07Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL07 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL08===========
        public static readonly DependencyProperty IsFL08Property = DependencyProperty.Register("IsFL08",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL08Changed));
        public bool IsFL08
        {
            get
            {
                return (bool)GetValue(IsFL08Property);
            }
            set
            {
                SetValue(IsFL08Property, value);
            }
        }
        private static void OnIsFL08Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL08 = (bool)e.NewValue;
            }
        }

        #endregion
        #region ==IsFL09===========
        public static readonly DependencyProperty IsFL09Property = DependencyProperty.Register("IsFL09",
            typeof(bool), typeof(UIJOB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFL09Changed));
        public bool IsFL09
        {
            get
            {
                return (bool)GetValue(IsFL09Property);
            }
            set
            {
                SetValue(IsFL09Property, value);
            }
        }
        private static void OnIsFL09Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIJOB;
            if (src != null)
            {
                src.IsFL09 = (bool)e.NewValue;
            }
        }

        #endregion
        public virtual void JobBase_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            this.AUF = "V" + AUF;
        }


        public string CONTENT
        {
            get;
            set;
        }

        #region=====Show=====
        public WrapPanel CN01
        {
            get
            {
                return this.FindName("C01") as WrapPanel;
            }
        }
        public WrapPanel CN02
        {
            get
            {
                return this.FindName("C01") as WrapPanel;
            }
        }
        public WrapPanel CN03
        {
            get
            {
                return this.FindName("C03") as WrapPanel;
            }
        }
        public WrapPanel CN10
        {
            get
            {
                return this.FindName("C10") as WrapPanel;
            }
        }
        public WrapPanel CN11
        {
            get
            {
                return this.FindName("C11") as WrapPanel;
            }
        }
        public WrapPanel CN12
        {
            get
            {
                return this.FindName("C12") as WrapPanel;
            }
        }
        public WrapPanel CN13
        {
            get
            {
                return this.FindName("C13") as WrapPanel;
            }
        }
        public WrapPanel CN14
        {
            get
            {
                return this.FindName("C14") as WrapPanel;
            }
        }
        public Grid CN21
        {
            get
            {
                return this.FindName("C21") as Grid;
            }
        }


        #endregion

        public virtual void Load()
        { }

      
        public virtual void Material()
        {

            switch (ProductionType)
            {
                case "Y":
                    GAKG1 = Convert.ToDouble(dwJob["JP11"].ToString());
                    GAKG2 = Convert.ToDouble(dwJob["JP12"].ToString());
                    GAKG3 = Convert.ToDouble(dwJob["JP13"].ToString());
                    GAKG4 = Convert.ToDouble(dwJob["JP14"].ToString());
                    GAKG5 = Convert.ToDouble(dwJob["JP15"].ToString());
                    GAKG6 = Convert.ToDouble(dwJob["JP16"].ToString());
                    GAKG7 = Convert.ToDouble(dwJob["JP17"].ToString());
                    MQTYPLAN = GAKG1;
                    MQTYBOOK = GAKG2 + GAKG3 + GAKG5;
                    MQTYUSED = GAKG6 + GAKG7;
                    NMQTYPLAN = Convert.ToDouble(dwJob["JP18"].ToString());
                    NMQTYBOOK = Convert.ToDouble(dwJob["JP18"].ToString());
                    break;
                case "R":
                    GAKG1 = Convert.ToDouble(dwJob["JP11"].ToString());
                    GAKG2 = Convert.ToDouble(dwJob["JP12"].ToString());
                    GAKG3 = Convert.ToDouble(dwJob["JP13"].ToString());
                    GAKG4 = Convert.ToDouble(dwJob["JP14"].ToString());
                    GAKG5 = Convert.ToDouble(dwJob["JP15"].ToString());
                    GAKG6 = Convert.ToDouble(dwJob["JP16"].ToString());
                    GAKG7 = Convert.ToDouble(dwJob["JP17"].ToString());
                    BAMTR1 = Convert.ToDouble(dwJob["JP31"].ToString());
                    BAMTR2 = Convert.ToDouble(dwJob["JP32"].ToString());
                    BAMTR3 = Convert.ToDouble(dwJob["JP33"].ToString());
                    BAMTR4 = Convert.ToDouble(dwJob["JP34"].ToString());
                    BAMTR5 = Convert.ToDouble(dwJob["JP35"].ToString());
                    BAMTR6 = Convert.ToDouble(dwJob["JP36"].ToString());
                    BAMTR7 = Convert.ToDouble(dwJob["JP37"].ToString());
                    MQTYPLAN = GAKG1;
                    MQTYBOOK = GAKG2 + GAKG3 + GAKG5;
                    MQTYUSED = GAKG6 + GAKG7;
                    NMQTYPLAN = Convert.ToDouble(dwJob["JP18"].ToString());
                    NMQTYBOOK = Convert.ToDouble(dwJob["JP18"].ToString());
                    break;
                case "V":
                    GAKG1 = Convert.ToDouble(dwJob["JP11"].ToString());
                    GAKG2 = Convert.ToDouble(dwJob["JP12"].ToString());
                    GAKG3 = Convert.ToDouble(dwJob["JP13"].ToString());
                    GAKG4 = Convert.ToDouble(dwJob["JP14"].ToString());
                    GAKG5 = Convert.ToDouble(dwJob["JP15"].ToString());
                    GAKG6 = Convert.ToDouble(dwJob["JP16"].ToString());
                    GAKG7 = Convert.ToDouble(dwJob["JP17"].ToString());

                    WDBEDARF = Convert.ToDouble(dwJob["JP38"].ToString());
                    WDZUGET = Convert.ToDouble(dwJob["JP39"].ToString());
                    WDRESERV = Convert.ToDouble(dwJob["JP41"].ToString());
                    MQTYPLAN = GAKG1;
                    MQTYBOOK = GAKG2 + GAKG3 + GAKG5;
                    MQTYUSED = GAKG6 + GAKG7;
                    NMQTYPLAN = Convert.ToDouble(dwJob["JP18"].ToString());
                    NMQTYBOOK = Convert.ToDouble(dwJob["JP18"].ToString());
                    break;
                case "F":
                    WDBEDARF = Convert.ToDouble(dwJob["JP38"].ToString());
                    WDZUGET = Convert.ToDouble(dwJob["JP39"].ToString());
                    WDRESERV = Convert.ToDouble(dwJob["JP41"].ToString());
                    MQTYPLAN = GAKG1;
                    MQTYBOOK = GAKG2 + GAKG3 + GAKG5;
                    MQTYUSED = GAKG6 + GAKG7;
                    NMQTYPLAN = Convert.ToDouble(dwJob["JP18"].ToString());
                    NMQTYBOOK = Convert.ToDouble(dwJob["JP18"].ToString());
                    break;
                case "W":
                    GAKG1 = Convert.ToDouble(dwJob["JP11"].ToString());
                    GAKG2 = Convert.ToDouble(dwJob["JP12"].ToString());
                    GAKG3 = Convert.ToDouble(dwJob["JP13"].ToString());
                    GAKG4 = Convert.ToDouble(dwJob["JP14"].ToString());
                    GAKG5 = Convert.ToDouble(dwJob["JP15"].ToString());
                    GAKG6 = Convert.ToDouble(dwJob["JP16"].ToString());
                    GAKG7 = Convert.ToDouble(dwJob["JP17"].ToString());
                    MQTYPLAN = GAKG1;
                    MQTYBOOK = GAKG2 + GAKG3 + GAKG5;
                    MQTYUSED = GAKG6 + GAKG7;
                    NMQTYPLAN = Convert.ToDouble(dwJob["JP18"].ToString());
                    NMQTYBOOK = Convert.ToDouble(dwJob["JP18"].ToString());
                    break;
                default:
                    break;
            }
        }

        public virtual void Production()
        {
            switch (ProductionType)
            {
                //ABPEALFM,ABPEAKG,ABPERLDAT,ABPERLKZ 
                case "Y":
                    QTYACT = Convert.ToDouble(dwJob["JP20"].ToString());
                    NPQTYPLAN = Convert.ToDouble(dwJob["JP22"].ToString());
                    PQTYPLAN = Convert.ToDouble(dwJob["JP21"].ToString());
                    JobQty = Convert.ToDouble(dwJob["JP05"].ToString());
                    break;
                default:
                    break;
            }
        }

        public virtual void JobMask()
        {
            if (dwMask == null)
                return;
            if (dwMask["PR01"].ToString() == "1") IsPR01 = true; else IsPR01 = false;
            if (dwMask["PR02"].ToString() == "1") IsPR02 = true; else IsPR02 = false;
            if (dwMask["PR03"].ToString() == "1") IsPR03 = true; else IsPR03 = false;
            if (dwMask["PR04"].ToString() == "1") IsPR04 = true; else IsPR04 = false;
            if (dwMask["PR05"].ToString() == "1") IsPR05 = true; else IsPR05 = false;
            if (dwMask["PR06"].ToString() == "1") IsPR06 = true; else IsPR06 = false;
            if (dwMask["PR07"].ToString() == "1") IsPR07 = true; else IsPR07 = false;
            if (dwMask["PR08"].ToString() == "1") IsPR08 = true; else IsPR08 = false;
            if (dwMask["PR09"].ToString() == "1") IsPR09 = true; else IsPR09 = false;
            if (dwMask["CN01"].ToString() == "1") IsCN01 = true; else IsCN01 = false;
            if (dwMask["CN02"].ToString() == "1") IsCN02 = true; else IsCN02 = false;
            if (dwMask["CN03"].ToString() == "1") IsCN03 = true; else IsCN03 = false;
            if (dwMask["CN04"].ToString() == "1") IsCN04 = true; else IsCN04 = false;
            if (dwMask["CN05"].ToString() == "1") IsCN05 = true; else IsCN05 = false;
            if (dwMask["CN06"].ToString() == "1") IsCN06 = true; else IsCN06 = false;
            if (dwMask["CN07"].ToString() == "1") IsCN07 = true; else IsCN07 = false;
            if (dwMask["CN08"].ToString() == "1") IsCN08 = true; else IsCN08 = false;
            if (dwMask["CN09"].ToString() == "1") IsCN09 = true; else IsCN09 = false;
            if (dwMask["DN01"].ToString() == "1") IsDN01 = true; else IsDN01 = false;
            if (dwMask["DN02"].ToString() == "1") IsDN02 = true; else IsDN02 = false;
            if (dwMask["DN03"].ToString() == "1") IsDN03 = true; else IsDN03 = false;
            if (dwMask["DN04"].ToString() == "1") IsDN04 = true; else IsDN04 = false;
            if (dwMask["DN05"].ToString() == "1") IsDN05 = true; else IsDN05 = false;
            if (dwMask["DN06"].ToString() == "1") IsDN06 = true; else IsDN06 = false;
            if (dwMask["DN07"].ToString() == "1") IsDN07 = true; else IsDN07 = false;
            if (dwMask["DN08"].ToString() == "1") IsDN08 = true; else IsDN08 = false;
            if (dwMask["DN09"].ToString() == "1") IsDN09 = true; else IsDN09 = false;
            if (dwMask["FL01"].ToString() == "1") IsFL01 = true; else IsFL01 = false;
            if (dwMask["FL02"].ToString() == "1") IsFL02 = true; else IsFL02 = false;
            if (dwMask["FL03"].ToString() == "1") IsFL03 = true; else IsFL03 = false;
            if (dwMask["FL04"].ToString() == "1") IsFL04 = true; else IsFL04 = false;
            if (dwMask["FL05"].ToString() == "1") IsFL05 = true; else IsFL05 = false;
            if (dwMask["FL06"].ToString() == "1") IsFL06 = true; else IsFL06 = false;
            if (dwMask["FL07"].ToString() == "1") IsFL07 = true; else IsFL07 = false;
            if (dwMask["FL08"].ToString() == "1") IsFL08 = true; else IsFL08 = false;
            if (dwMask["FL09"].ToString() == "1") IsFL09 = true; else IsFL09 = false;

        }

        public virtual void MoreSteps(object sender, System.Windows.RoutedEventArgs e)
        {
            this.Width = this.ActualWidth * 2;
        }
        public virtual void BackwardMU(object sender, System.Windows.RoutedEventArgs e)
        {

        }

        public virtual void ForwardToMU(object sender, System.Windows.RoutedEventArgs e)
        {

        }
    }
}
